package number5;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class copy extends Thread{
	private File sourceFile;
	private File destFile;

	public copy(File sourceFile, File destFile) {
		super();
		this.sourceFile = sourceFile;
		this.destFile = destFile;
	}

	@Override
	public void run() {
		 try {
	            FileInputStream in = new FileInputStream(sourceFile);
	            FileOutputStream out = new FileOutputStream(destFile);

	            byte[] buffer = new byte[1024];
	            int length;
	            while ((length = in.read(buffer)) > 0) {
	                out.write(buffer, 0, length);
	            }

	            in.close();
	            out.close();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	}
}
